package sg4c.frontend.command;

import java.io.IOException;
import sg4c.frontend.GraphicsContext;
import sg4c.protocol.DataInputProtocol;

public class DrawPoint implements GraphicsCommand {

    private final int x;
    private final int y;
    
    public DrawPoint(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public void execute(GraphicsContext context) {
        if (!context.noStroke()) {
            context.loadStrokeColor();
            context.getGraphics().drawLine(x, y, x, y);
        }
    }
    public static final Factory factory = new Factory() {

        public GraphicsCommand parse(DataInputProtocol in) throws IOException {
            int x = in.readInt();
            int y = in.readInt();
            return new DrawPoint(x, y);
        }
    };
}
